package com.youngjun.common.pojo.dto.support;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.dozer.DozerBeanMapperBuilder;
import org.dozer.Mapper;

/**
 * @author YoungJun
 */
public class BaseDTO<DTO> {

    /**
     * DO to VO
     *
     * @return
     */
    @JsonIgnore
    public Mapper getDTOMapper() {
        return DozerBeanMapperBuilder.create().build();
    }

    public DTO mapFrom(Object src, Mapper mapper) {
        if (src != null){
            mapper.map(src, this);
        }
        return (DTO) this;
    }

    public DTO mapFrom(Object src) {
        return mapFrom(src, getDTOMapper());
    }
}